#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include "process.h"


const int base = 20;//网速
double total = 2048.0;//要下载的内存大小
double once = 0.1;

void dowmload()
{
    double current = 0.0;

    while(current < total)
    {
        //模拟下载行为
        int r = rand()%base +1;//网速范围在【1，base】
        double speed = r * once;
        current += speed;

        if(current >= total)
            current = total;

        usleep(10000);
       // printf("test: %.1lf/%.1lf\r", current, total);
       // fflush(stdout);

        //实际应用进度条
        Process(total,current);
    }

    printf("\n");

}


int main()
{
    srand(time(NULL));
    dowmload();

    return 0;
}
